package com.yun.datastructure.tree.binarytree.leetcode;

import com.yun.datastructure.tree.binarytree.domain.TreeNode;

public class Leetcode226 {
    public TreeNode invertTree(TreeNode root) {
        if(root==null){
            return null;
        }
        invertTree(root.left);
        invertTree(root.right);
        TreeNode t=root.left;
        root.left=root.right;
        root.right=t;
        return root;
    }

    private void preorder(TreeNode Node){
        if(Node==null){
            return;
        }
        System.out.print(Node.val+"\t");
        preorder(Node.left);
        preorder(Node.right);
    }

    public static void main(String[] args) {
        TreeNode root = new TreeNode(
                new TreeNode(new TreeNode(4), 2, new TreeNode(7)),
                1,
                new TreeNode(new TreeNode(5), 3, new TreeNode(6))
        );
    }
}
